<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of parkway
 *
 * @author Gidaff_01
 */
class parkway extends Doggy_Flirt_FrontEnd_Controller{
    //put your code here
    function Parkway() {
        parent::Doggy_Flirt_FrontEnd_Controller();
        $this->load->model('Doggy_admin_m');
        $this->load->model('Home_m');
        $this->load->helper('date');
        $this->_data['erreur'] = "";
    }

    function detail_parkway($id){
        $query = $this->Doggy_admin_m->get_parkway_by_id($id);
        $this->_data['parkway_detail'] = $query;
        $this->display_view('parkway/detail_parkway');
    }

    function list_parkway() {
        $per_page = $this->uri->segment(3);
        if ($per_page == "") {
            $per_page = 5;
        }
        $off_set = $this->uri->segment(4);
        if ($off_set == "") {
            $off_set = 0;
        }
        $config['base_url'] = base_url() . 'index.php/parkway/list_parkway/' . '/' . $per_page . '/';
        $config['per_page'] = '5';
        $config['uri_segment'] = 4;
        $config['total_rows'] = $this->Doggy_admin_m->count_parkway();
        if ($off_set > 0 && $off_set == $config['total_rows']) {
            $off_set = $off_set - $per_page;
        }
        $this->_data['query'] = $this->Doggy_admin_m->list_parkway($config['per_page'], $off_set);
        $this->pagination->initialize($config);
        $this->_data['pagination'] = $this->pagination->create_links();
        $this->_data['total'] = $this->Doggy_admin_m->count_parkway();
        $this->_data['page_title'] = "Liste de parkway";
        $this->_data['per_page'] = $per_page;
        $this->_data['off_set'] = $off_set;
        $this->display_view('parkway/list_parkway');
    }

    function search_parkway() {
        if ($this->input->post('search')) {
            $region = $this->input->post('search_region');
            $this->_data['selected_region'] = $region;
            if ($region != null && $region != '') {
                $per_page = $this->uri->segment(3);
                if ($per_page == "") {
                    $per_page = 10;
                }
                $off_set = $this->uri->segment(4);
                if ($off_set == "") {
                    $off_set = 0;
                }
                $config['base_url'] = base_url() . 'index.php/parkway/search_parkway/' . $region . '/' . $per_page . '/';
                $config['per_page'] = $per_page;
                $config['uri_segment'] = 4;
                $config['total_rows'] = $this->Doggy_admin_m->count_search_parkway($region);
                if ($off_set > 0 && $off_set == $config['total_rows']) {
                    $off_set = $off_set - $per_page;
                }
                $this->_data['query'] = $this->Doggy_admin_m->search_parkway($region, $config['per_page'], $off_set);
                $this->pagination->initialize($config);
                $this->_data['pagination'] = $this->pagination->create_links();
                $this->_data['total'] = $this->Doggy_admin_m->count_search_parkway($region);
                $this->_data['page_title'] = "Liste de parkway";
                $this->_data['per_page'] = $per_page;
                $this->_data['off_set'] = $off_set;
                $this->_data['parkway_search'] = $region;
                $this->display_view('parkway/list_parkway');
            } else {
                $this->list_parkway();
            }
        } else {
            $this->display_view('parkway/list_parkway');
        }
    }

    function search_parkway_page() {
        $region = $this->uri->segment(3);
        $this->_data['selected_region'] = $region;
        $per_page = $this->uri->segment(4);
        if ($per_page == "") {
            $per_page = 10;
        }
        $off_set = $this->uri->segment(5);
        if ($off_set == "") {
            $off_set = 0;
        }
        $config['base_url'] = base_url() . 'index.php/parkway/search_parkway/' . $region . '/' . $per_page . '/';
        $config['per_page'] = $per_page;
        $config['uri_segment'] = 5;
        $config['total_rows'] = $this->Doggy_admin_m->count_search_parkway($region);
        if ($off_set > 0 && $off_set == $config['total_rows']) {
            $off_set = $off_set - $per_page;
        }
        $this->_data['query'] = $this->Doggy_admin_m->search_parkway($region, $config['per_page'], $off_set);
        $this->pagination->initialize($config);
        $this->_data['pagination'] = $this->pagination->create_links();
        $this->_data['total'] = $this->Doggy_admin_m->count_search_parkway($region);
        $this->_data['page_title'] = "Liste de parkway";
        $this->_data['per_page'] = $per_page;
        $this->_data['off_set'] = $off_set;
        $this->_data['parkway_search'] = $city;
        $this->display_view('parkway/list_parkway');
    }
}
?>
